<!-- You must include this JavaScript file -->
<script src="https://assets.crowd.aws/crowd-html-elements.js"></script>

<!-- For the full list of available Crowd HTML Elements and their input/output documentation,
You are going to be first asked 2 questions about your preferences over risky options, then a few demographic questions.<br>
    In addition to your HIT payment, the requester will play out your preferred option in one of the 2 preference questions.<br>
    If the first question is selected and you win, you will receive an additional $10 payment.<br>
    If the second question is selected and you win, you will receive an additional $1 payment.

      please refer to https://docs.aws.amazon.com/sagemaker/latest/dg/sms-ui-template-reference.html -->


<h3>Please read all instructions!!</h3>
<h4>You are going to be first asked 2 questions about your preferences, then a few demographic questions.<br>
    In each of the 2 preference questions, you will play out your preferred option.<br>
    If you win in either question, you will receive a $10 bonus payment in addition to your HIT payment for each question you win.<br>
    The bonus payment will be applied directly to your MTurk account via your Worker ID within 3 business days.<br>
    If you do not win in either question, you will still receive your HIT payment.</h4>
  
<script>

function getNumber(min,max) {
    min = Math.ceil(min);
    max = Math.floor(max);
    randomnumber = Math.floor(Math.random() * (max - min + 1)) + min; //The maximum is exclusive and the minimum is inclusive
    return randomnumber;
}
  
  rand1=getNumber(0,999);
  rand2=getNumber(0,999);
  
function callit1(){
   document.getElementById("get1").innerHTML = rand1;
   document.getElementById("comp_store1").value = rand1;
}
function callit2(){
   document.getElementById("get2").innerHTML = rand2;
   document.getElementById("comp_store2").value = rand2;
}
function callit3(){
   document.getElementById("get3").innerHTML = rand3;
   document.getElementById("game_store1").value = rand3;
}
function callit4(){
    if (document.getElementById("P1.1").checked == true){
        document.getElementById("random").innerHTML = '';
        document.getElementById("P1.1exp").innerHTML = '<h3>Option 2. Click on the two buttons below to see if the numbers drawn match</h3>';
        document.getElementById("P1.1b1").innerHTML = '<button type="button" name="comp1" value="1" id="get1" onclick = "callit1()">first draw</button>';
        document.getElementById("P1.1b2").innerHTML = '<button type="button" name="comp2" value="1" id="get2" onclick = "callit2()">second draw</button>';
        document.getElementById("P1.2exp").innerHTML = '';
        document.getElementById("P1.2b1").innerHTML = '';
        document.getElementById("P1.2b2").innerHTML = '';
    }
    
    if (document.getElementById("P1.2").checked == true){
        document.getElementById("random").innerHTML = '';
        document.getElementById("P1.1exp").innerHTML = '';
        document.getElementById("P1.1b1").innerHTML = '';
        document.getElementById("P1.1b2").innerHTML = '';
        document.getElementById("P1.2exp").innerHTML = '<h3>Option 1. Please input your lucky number</h3>';
        document.getElementById("P1.2b1").innerHTML = '<input name="lucky1" id="lucky1" maxlength="3" placeholder="Enter your lucky number" type="text">';
        document.getElementById("P1.2b2").innerHTML = '<button type="button" name="confirm1" id="get3" onclick="lock()">click to lock your number and have the computer draw a number</button>';
    }
    
    if (document.getElementById("P1.3").checked == true){
        rand4=getNumber(1,2);
    if (rand4 == 1){
        document.getElementById("random").innerHTML = '<h3>It was randomly determined that you will play out Option 2.<br>';
        document.getElementById("P1.1exp").innerHTML = '<h3>Option 2. Click on the two buttons below to see if the numbers drawn match</h3>';
        document.getElementById("P1.1b1").innerHTML = '<button type="button" name="comp1" value="1" id="get1" onclick = "callit1()">first draw</button>';
        document.getElementById("P1.1b2").innerHTML = '<button type="button" name="comp2" value="1" id="get2" onclick = "callit2()">second draw</button>';
        document.getElementById("P1.2exp").innerHTML = '';
        document.getElementById("P1.2b1").innerHTML = '';
        document.getElementById("P1.2b2").innerHTML = '';
   }
    if (rand4 == 2){
        document.getElementById("random").innerHTML = '<h3>It was randomly determined that you will play out Option 1.<br>';
        document.getElementById("P1.1exp").innerHTML = '';
        document.getElementById("P1.1b1").innerHTML = '';
        document.getElementById("P1.1b2").innerHTML = '';
        document.getElementById("P1.2exp").innerHTML = '<h3>Option 1. Please input your lucky number</h3>';
        document.getElementById("P1.2b1").innerHTML = '<input name="lucky1" id="lucky1" maxlength="3" placeholder="Enter your lucky number" type="text">';
        document.getElementById("P1.2b2").innerHTML = '<button type="button" name="confirm1" id="get3" onclick="lock()">click to lock your number and have the computer draw a number</button>';
   }
}
}
function lock(){
    rand3=getNumber(0,999); 
    document.getElementById("lucky1").readOnly=true;
    document.getElementById("get3").innerHTML = rand3;
    document.getElementById("game_store1").value = rand3;
}

     rand1a=getNumber(0,999999); 
     rand2a=getNumber(0,999999); 

function callit1a(){
   document.getElementById("get1a").innerHTML = rand1a;
   document.getElementById("comp_store1a").value = rand1a;
}
function callit2a(){
   document.getElementById("get2a").innerHTML = rand2a;
   document.getElementById("comp_store2a").value = rand2a;
}
function callit3a(){
   document.getElementById("get3a").innerHTML = rand3a;
   document.getElementById("game_store1a").value = rand3a;
}
function callit4a(){
   if (document.getElementById("P1a.1").checked == true){
        document.getElementById("randoma").innerHTML = '';
        document.getElementById("P1a.1exp").innerHTML = '<h3>Option 2. Click on the two buttons below to see if the numbers drawn match</h3>';
        document.getElementById("P1a.1b1").innerHTML = '<button type="button" name="comp1a" value="1" id="get1a" onclick = "callit1a()">first draw</button>';
        document.getElementById("P1a.1b2").innerHTML = '<button type="button" name="comp2a" value="1" id="get2a" onclick = "callit2a()">second draw</button>';
        document.getElementById("P1a.2exp").innerHTML = '';
        document.getElementById("P1a.2b1").innerHTML = '';
        document.getElementById("P1a.2b2").innerHTML = '';
    }
    
    if (document.getElementById("P1a.2").checked == true){
        document.getElementById("randoma").innerHTML = '';
        document.getElementById("P1a.1exp").innerHTML = '';
        document.getElementById("P1a.1b1").innerHTML = '';
        document.getElementById("P1a.1b2").innerHTML = '';
        document.getElementById("P1a.2exp").innerHTML = '<h3>Option 1. Please input your lucky number</h3>';
        document.getElementById("P1a.2b1").innerHTML = '<input name="lucky1a" id="lucky1a" maxlength="6" placeholder="Enter your lucky number" type="text">';
        document.getElementById("P1a.2b2").innerHTML = '<button type="button" name="confirm1a" id="get3a" onclick="locka()">click to lock your number and have the computer draw a number</button>';
    }
    
    if (document.getElementById("P1a.3").checked == true){
        rand4a=getNumber(1,2);
    if (rand4a == 1){
        document.getElementById("randoma").innerHTML = '<h3>It was randomly determined that you will play out Option 2.<br>';
        document.getElementById("P1a.1exp").innerHTML = '<h3>Option 2. Click on the two buttons below to see if the numbers drawn match</h3>';
        document.getElementById("P1a.1b1").innerHTML = '<button type="button" name="comp1a" value="1" id="get1a" onclick = "callit1a()">first draw</button>';
        document.getElementById("P1a.1b2").innerHTML = '<button type="button" name="comp2a" value="1" id="get2a" onclick = "callit2a()">second draw</button>';
        document.getElementById("P1a.2exp").innerHTML = '';
        document.getElementById("P1a.2b1").innerHTML = '';
        document.getElementById("P1a.2b2").innerHTML = '';
   }
    if (rand4a == 2){
        document.getElementById("randoma").innerHTML = '<h3>It was randomly determined that you will play out Option 1.<br>';
        document.getElementById("P1a.1exp").innerHTML = '';
        document.getElementById("P1a.1b1").innerHTML = '';
        document.getElementById("P1a.1b2").innerHTML = '';
        document.getElementById("P1a.2exp").innerHTML = '<h3>Option 1. Please input your lucky number</h3>';
        document.getElementById("P1a.2b1").innerHTML = '<input name="lucky1a" id="lucky1a" maxlength="6" placeholder="Enter your lucky number" type="text">';
        document.getElementById("P1a.2b2").innerHTML = '<button type="button" name="confirm1a" id="get3a" onclick="locka()">click to lock your number and have the computer draw a number</button>';
   }
}
}
function locka(){
    rand3a=getNumber(0,999999); 
    document.getElementById("lucky1a").readOnly=true;
    document.getElementById("get3a").innerHTML = rand3a;
    document.getElementById("game_store1a").value = rand3a;
}
</script>

  <!-- You must include crowd-form so that your task submits answers to MTurk -->
<crowd-form answer-format="flatten-objects"> 

<h2>Question 1
<br>Consider the following options:</h2>
Option 1. Picking any number you want from 0-999 and then letting a computer randomly pick a number from 0-999. If the numbers match, you win $10 (Ten dollars); otherwise you receive $0.<br>
Option 2. Letting a computer randomly pick a number between 0-999 two separate times. If it picks the same number each time you receive $10 (Ten dollars); otherwise, you receive $0.


<!--<h4>Note that the probabilitiles, payoffs and expected value (the long-run average payout) of the options are exactly the same, $10.</h4>-->
<h3>You will actually play out your preferred option. If you value both options equally, you will be assigned one of the two options randomly.</h3>
Which option would you prefer?<br>
<div class="radio"><label><input name="P1" id="P1.2" required="" type="radio" value="1" onclick = "callit4()"/></label>Option 1</div>
<div class="radio"><label><input name="P1" id="P1.1" required="" type="radio" value="2" onclick = "callit4()"/></label>Option 2</div>
<div class="radio"><label><input name="P1" id="P1.3" required="" type="radio" value="3" onclick = "callit4()"/></label>I value both options equally</div>

<h3>You are now going to play out your preferred option.</h3>

<p id="random"></p>
<p id="P1.1exp"></p>
<p id="P1.1b1"></p>
<p id="P1.1b2"></p>
<p id="P1.2exp"></p>
<p id="P1.2b1"></p>
<p id="P1.2b2"></p>

<input hidden id="comp_store1" name="compstore1"/>
<input hidden id="comp_store2" name="compstore2"/>
<input hidden id="game_store1" name="gamestore1"/>
<input hidden id="indifferent1" name="indifferent1"/>

<br>
<br>

<h2>Question 2
<br>Consider the following options:</h2>
Option 1. Picking any number you want from 0-999,999 and then letting a computer randomly pick a number from 0-999,999. If the numbers match, you win $10 (Ten dollars); otherwise you receive $0.<br>
Option 2. Letting a computer randomly pick a number between 0-999,999 two separate times. If it picks the same number each time you receive $10 (Ten dollars); otherwise, you receive $0.


<!--<h4>Note that the probabilitiles, payoffs and expected value (the long-run average payout) of the options are exactly the same, $10.</h4>-->
<h3>You will actually play out your preferred option. If you value both options equally, you will be assigned one of the two options randomly.</h3>
Which option would you prefer?<br>
<div class="radio"><label><input name="P1a" id="P1a.2" required="" type="radio" value="1" onclick = "callit4a()"/></label>Option 1</div>
<div class="radio"><label><input name="P1a" id="P1a.1" required="" type="radio" value="2" onclick = "callit4a()"/></label>Option 2</div>
<div class="radio"><label><input name="P1a" id="P1a.3" required="" type="radio" value="3" onclick = "callit4a()"/></label>I value both options equally</div>

<h3>You are now going to play out your preferred option.</h3>

<p id="randoma"></p>
<p id="P1a.1exp"></p>
<p id="P1a.1b1"></p>
<p id="P1a.1b2"></p>
<p id="P1a.2exp"></p>
<p id="P1a.2b1"></p>
<p id="P1a.2b2"></p>

<input hidden id="comp_store1a" name="compstore1a"/>
<input hidden id="comp_store2a" name="compstore2a"/>
<input hidden id="game_store1a" name="gamestore1a"/>
<input hidden id="indifferent1a" name="indifferent1a"/>

<br>
<br>

<h1> Survey</h1>

1. What is your age?
<br>
<div class="radio"><label><input name="Q1" required="" type="radio" value="1" /></label>Under 21</div>
<div class="radio"><label><input name="Q1" required="" type="radio" value="2" /></label>21-30</div>
<div class="radio"><label><input name="Q1" required="" type="radio" value="3" /></label>31-40</div>
<div class="radio"><label><input name="Q1" required="" type="radio" value="4" /></label>41-50</div>
<div class="radio"><label><input name="Q1" required="" type="radio" value="5" /></label>51-60</div>
<div class="radio"><label><input name="Q1" required="" type="radio" value="6" /></label>Over 60</div>
<div class="radio">&nbsp;</div>

2. What is your gender?
<br>
<div class="radio"><label><input name="Q2" required="" type="radio" value="1" /></label>Male</div>
<div class="radio"><label><input name="Q2" required="" type="radio" value="2" /></label>Female</div>
<div class="radio"><label><input name="Q2" required="" type="radio" value="3" /></label>Other</div>
<div class="radio">&nbsp;</div>

3. Do you work in paid employment besides MTurk?
<br>
<div class="radio"><label><input name="Q3" required="" type="radio" value="1" /></label>Yes</div>
<div class="radio"><label><input name="Q3" required="" type="radio" value="2" /></label>No</div>
<div class="radio">&nbsp;</div>

4. Do you know anyone who won a significant amount of money from a lottery in the past five years?
<br>
<div class="radio"><label><input name="Q4" required="" type="radio" value="1" /></label>Yes</div>
<div class="radio"><label><input name="Q4" required="" type="radio" value="2" /></label>No</div>
<div class="radio">&nbsp;</div>

5. What are the combined balances in all of your accounts (amounts are in US dollars)?
<br>
<div class="radio"><label><input name="Q5" required="" type="radio" value="1" /></label>Under $100</div>
<div class="radio"><label><input name="Q5" required="" type="radio" value="2" /></label>$101-$500</div>
<div class="radio"><label><input name="Q5" required="" type="radio" value="3" /></label>$501-$1,000</div>
<div class="radio"><label><input name="Q5" required="" type="radio" value="4" /></label>$1,001-$2,000</div>
<div class="radio"><label><input name="Q5" required="" type="radio" value="5" /></label>$2,001-$5,000</div>
<div class="radio"><label><input name="Q5" required="" type="radio" value="6" /></label>$5,001-$10,000</div>
<div class="radio"><label><input name="Q5" required="" type="radio" value="7" /></label>Over $10,000</div>
<div class="radio">&nbsp;</div>

6. What is your total debt (not including mortgage, but including student loans, ongoing credit card debt, other types of debt)?
<br>
<div class="radio"><label><input name="Q6" required="" type="radio" value="1" /></label>Under $100</div>
<div class="radio"><label><input name="Q6" required="" type="radio" value="2" /></label>$101-$500</div>
<div class="radio"><label><input name="Q6" required="" type="radio" value="3" /></label>$501-$1,000</div>
<div class="radio"><label><input name="Q6" required="" type="radio" value="4" /></label>$1,001-$2,000</div>
<div class="radio"><label><input name="Q6" required="" type="radio" value="5" /></label>$2,001-$5,000</div>
<div class="radio"><label><input name="Q6" required="" type="radio" value="6" /></label>$5,001-$10,000</div>
<div class="radio"><label><input name="Q6" required="" type="radio" value="7" /></label>$10,001-$20,000</div>
<div class="radio"><label><input name="Q6" required="" type="radio" value="8" /></label>$20,001-$50,000</div>
<div class="radio"><label><input name="Q6" required="" type="radio" value="9" /></label>$50,001-$100,000</div>
<div class="radio"><label><input name="Q6" required="" type="radio" value="10" /></label>Over $100,000</div>
<div class="radio">&nbsp;</div>

7. Which best describes your purchases of lottery products over the past year?
<br>
<div class="radio"><label><input name="Q7" required="" type="radio" value="1" /></label>Daily</div>
<div class="radio"><label><input name="Q7" required="" type="radio" value="2" /></label>A few times a week</div>
<div class="radio"><label><input name="Q7" required="" type="radio" value="3" /></label>A few times a month</div>
<div class="radio"><label><input name="Q7" required="" type="radio" value="4" /></label>A few times a year</div>
<div class="radio"><label><input name="Q7" required="" type="radio" value="5" /></label>Never</div>
<div class="radio">&nbsp;</div>

8. Which best describes how often you have gambled at a casino or online over the past year?
<br>
<div class="radio"><label><input name="Q8" required="" type="radio" value="1" /></label>Daily</div>
<div class="radio"><label><input name="Q8" required="" type="radio" value="2" /></label>A few times a week</div>
<div class="radio"><label><input name="Q8" required="" type="radio" value="3" /></label>A few times a month</div>
<div class="radio"><label><input name="Q8" required="" type="radio" value="4" /></label>A few times a year</div>
<div class="radio"><label><input name="Q8" required="" type="radio" value="5" /></label>Never</div>
<div class="radio">&nbsp;</div>

9. Which best describes how often you have wagered or placed bets over the past year?
<br>
<div class="radio"><label><input name="Q9" required="" type="radio" value="1" /></label>Daily</div>
<div class="radio"><label><input name="Q9" required="" type="radio" value="2" /></label>A few times a week</div>
<div class="radio"><label><input name="Q9" required="" type="radio" value="3" /></label>A few times a month</div>
<div class="radio"><label><input name="Q9" required="" type="radio" value="4" /></label>A few times a year</div>
<div class="radio"><label><input name="Q9" required="" type="radio" value="5" /></label>Never</div>
<div class="radio">&nbsp;</div>

<h3>Human Check: Please select "7" below</h3>
<div class="radio"><label><input name="Qb" required="" type="radio" value="1" /></label>4</div>
<div class="radio"><label><input name="Qb" required="" type="radio" value="2" /></label>6</div>
<div class="radio"><label><input name="Qb" required="" type="radio" value="3" /></label>1</div>
<div class="radio"><label><input name="Qb" required="" type="radio" value="4" /></label>7</div>
<div class="radio"><label><input name="Qb" required="" type="radio" value="5" /></label>9</div>
<div class="radio"><label><input name="Qb" required="" type="radio" value="6" /></label>2</div>
<div class="radio"><label><input name="Qb" required="" type="radio" value="7" /></label>5</div>
<div class="radio"><label><input name="Qb" required="" type="radio" value="8" /></label>8</div>
<div class="radio"><label><input name="Qb" required="" type="radio" value="9" /></label>3</div>
<div class="radio">&nbsp;</div>



  </crowd-form>
